package com.focus.xyz.core.common.listeners;

import com.focus.xyz.core.utils.prop.ConfigPropInfo;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;

import java.io.File;

/**
 * Created by chenmeng on 2016/5/20.
 */
public class TC {
    private WebDriver driver;
    public WebDriver getDriver(){
        return this.driver;
    }

    public void setDriver(WebDriver driver){
        this.driver = driver;
    }

    public void init(WebDriver driver){
        setDriver(driver);
    }

    public void quit(){
        driver.quit();
    }


    public void takeScreenShot(String path) {
        File scrFile = (File)((TakesScreenshot)getDriver()).getScreenshotAs(OutputType.FILE);
        try {
            FileUtils.copyFile(scrFile, new File(path),false);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
        }
    }
}
